package hotel.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import hotel.dao.IDao;
import hotel.service.IService;

@Component
public class ServiceImpl<T> implements IService<T> {

	@Autowired
	protected IDao<T> dao;
	
	@Override
	public T findById(Class<T> clazz, int id) {
		return dao.findById(clazz, id);
	}

	@Override
	public boolean save(T obj) {
		return dao.save(obj);
	}

	@Override
	public boolean update(T obj) {
		return dao.update(obj);
	}

	@Override
	public boolean delete(T obj) {
		return dao.delete(obj);
	}

	@Override
	public boolean deleteById(String upperCaseClazz, int id) {
		return dao.deleteById(upperCaseClazz, id);
	}

	@Override
	public T findFirstResult(String hql) {
		return dao.findFirstResult(hql);
	}

	@Override
	public List<T> listAll(String entityName) {
		return dao.listAll(entityName);
	}

	@Override
	public List<T> paging(String entityName,int firstResult, int maxResult) {
		return dao.paging(entityName,firstResult,maxResult);
	}

	@Override
	public int getTotalCount(String entityName) {
		return dao.getTotalCount(entityName);
	}

	@Override
	public List<T> list(String hql) {
		return dao.list(hql);
	}

}
